package so.shanku.essential.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.tsz.afinal.toast.ToastUtil;
import so.shanku.essential.activity.base.BaseActivity;
import so.shanku.essential.getdata.GetServicesDataUtil;
import so.shanku.essential.utils.LogUtil;
import net.tsz.afinal.loading.MyLoadingDataDialogManager;

/**
 * Created by Jaelyn on 2015/8/20 0020.
 */
public class BaseFragment extends Fragment {
	protected String TAG = BaseFragment.class.getSimpleName();
	/**
	 * 提示toast的展示对象 可直接调用期show方法展示文字
	 */
	protected ToastUtil toast;
	/**
	 * 模拟toast展示加载数据的对话框，使界面更加友好
	 */
	protected MyLoadingDataDialogManager loadingToast;
	protected BaseActivity activity;
	/**
	 * 调用服务器接口获取服务器数据的工具
	 */
	protected GetServicesDataUtil getDataUtil;
	public BaseFragment() {
		super();
		LogUtil.d(TAG, "constructor");
		getDataUtil = GetServicesDataUtil.init();
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		LogUtil.d(TAG, "onAttach");
		this.activity = (BaseActivity) activity;
		this.toast = ((BaseActivity) activity).toast;
		this.loadingToast = ((BaseActivity) activity).loadingToast;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		LogUtil.d(TAG, "onCreateView");
		return null;
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		LogUtil.d(TAG, "onViewCreated");
		super.onViewCreated(view, savedInstanceState);
	}

	@Override
	public void onHiddenChanged(boolean hidden) {
		LogUtil.d(TAG, "onHiddenChanged");

		super.onHiddenChanged(hidden);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		LogUtil.d(TAG, "onCreate");
		super.onCreate(savedInstanceState);
		setRetainInstance(true);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		LogUtil.d(TAG, "onActivityCreated");

		super.onActivityCreated(savedInstanceState);
	}

	@Override
	public void onStart() {
		super.onStart();
	}

	@Override
	public void onResume() {
		super.onResume();
	}

	@Override
	public void onPause() {
		super.onPause();
	}

	@Override
	public void onStop() {
		super.onStop();
	}

	@Override
	public void onDestroyView() {
		LogUtil.d(TAG, "onDestroyView");

		super.onDestroyView();
	}

	@Override
	public void onDestroy() {
		LogUtil.d(TAG, "onDestroy");
		super.onDestroy();
	}

	@Override
	public void onDetach() {
		LogUtil.d(TAG, "onDetach");
		super.onDetach();
	}

    /**
     * back 键处理
     * @return   true：消费此次返回  false  不处理
     */
   public boolean backKeyClick(){
       return false;
   }
}